package com.dz.lm.common.util;

import java.util.Map;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.jpush.api.JPushClient;
import cn.jpush.api.common.APIConnectionException;
import cn.jpush.api.common.APIRequestException;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;

/**
 * JPushUtils
 * @author zhanghairong
 */
public class JPushUtils {
	/**
	 * read in properties file
	 */
	public static ResourceBundle jpush = ResourceBundle.getBundle("JPush");

	private static String APP_KEY = jpush.getString("APP_KEY");
	private static String MASTER_SECRET = jpush.getString("MASTER_SECRET");
	private static final Logger log = LoggerFactory.getLogger(JPushUtils.class);
 	private static JPushClient jpushClient = null;
 	private static PushResult pushResult = null;
 	private static PushPayload pushPayload = null;
	
	/**
	 * push all[user-defined](radio) 
	 * @param msgContent
	 * @return push result
	 */
	public static boolean pushMessageAll(String msgContent){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return false;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {
     		pushResult = jpushClient.sendMessageAll(msgContent);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
 		return pushResult.isResultOK();
	}

	/**
	 * push message to Android by alias.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param alias
	 */
	public static void pushAndroidMessageByAlias(String title, String msgContent, String... alias){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {
     		pushResult = jpushClient.sendAndroidMessageWithAlias(title, msgContent, alias);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push message to Android by registrationID.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param registrationID
	 */
	public static void pushAndroidMessageByRegistrationID(String title, String msgContent, String... registrationID){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {
     		pushResult = jpushClient.sendAndroidMessageWithRegistrationID(title, msgContent, registrationID);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}

	/**
	 * push message to Android by tag.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param tags
	 */
	public static void pushAndroidMessageByTag(String title, String msgContent, String... tags){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_tag_alert(title, msgContent, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push message to IOS by alias.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param alias
	 */
	public static void pushIosMessageByAlias(String title, String msgContent, String... alias){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {
     		pushResult = jpushClient.sendIosMessageWithAlias(title, msgContent, alias);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push message to IOS by registrationID.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param registrationID
	 */
	public static void pushIosMessageByRegistrationID(String title, String msgContent, String... registrationID){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {
     		pushResult = jpushClient.sendIosMessageWithRegistrationID(title, msgContent, registrationID);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Message to IOS by tag.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param tags
	 */
	public static void pushIosMessageByTag(String title, String msgContent, String... tags){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_ios_tag_alert(title, msgContent, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Message to Android&IOS by tag.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param tags
	 */
	public static void pushAndroidIosMessageByTag(String title, String msgContent, String... tags){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_tag_alert(title, msgContent, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Message to Android&IOS by alias.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param alias
	 */
	public static void pushAndroidIosMessageByAlias(String title, String msgContent, String... alias){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_alias_alert(title, msgContent, alias);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Message to Android&IOS by registrationID.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param registrationID
	 */
	public static void pushAndroidIosMessageByRegistrationID(String title, String msgContent, String... registrationID){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_registrationId_alert(title, msgContent, registrationID);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Message to Android&IOS&Winphone by registrationID.[user-defined]
	 * @param title
	 * @param msgContent 
	 * @param registrationID
	 */
	public static void pushAllMessageByRegistrationID(String title, String msgContent, String... registrationID){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Message content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_all_registrationId_alert(title, msgContent, registrationID);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Message: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push all[Notification](radio) 
	 * @param msgContent
	 * @return push result
	 */
	public static boolean pushNotificationAll(String msgContent){

		if (msgContent == null || msgContent.isEmpty()) {
			log.info("Notification content is empty.");
			return false;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {     		
     		pushResult = jpushClient.sendNotificationAll(msgContent);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
 		return pushResult.isResultOK();
	}
	
	/**
	 * push Notification to Android by alias 
	 * @param title
	 * @param alert
	 * @param extras
	 * @param alias 
	 */
	public static void pushAndroidNotificationByAlias(String title, String alert, 
            Map<String, String> extras, String... alias){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {     		
     		pushResult = jpushClient.sendAndroidNotificationWithAlias(title, alert, extras, alias);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to Android by RegistrationID 
	 * @param title
	 * @param alert
	 * @param extras
	 * @param registrationID 
	 */
	public static void pushAndroidNotificationByRegistrationID(String title, String alert, 
            Map<String, String> extras, String... registrationID){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {     		
     		pushResult = jpushClient.sendAndroidNotificationWithRegistrationID(title, alert, extras, registrationID);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to Android by tag 
	 * @param title
	 * @param alert
	 * @param extras
	 * @param tags 
	 */
	public static void pushAndroidNotificationByTag(String title, String alert, Map<String, String> extras, String... tags){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_tag_notification(title, alert, extras, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to IOS by alias 
	 * @param alert
	 * @param extras
	 * @param alias 
	 */
	public static void pushIosNotificationByAlias(String alert, Map<String, String> extras, String... alias){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {     		
     		pushResult = jpushClient.sendIosNotificationWithAlias(alert, extras, alias);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}

	/**
	 * push Notification to IOS by RegistrationID 
	 * @param alert
	 * @param extras
	 * @param registrationID 
	 */
	public static void pushIosNotificationByRegistrationID(String alert, Map<String, String> extras, String... registrationID){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	try {     		
     		pushResult = jpushClient.sendIosNotificationWithRegistrationID(alert, extras, registrationID);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
    
	/**
	 * push Notification to IOS by tag 
	 * @param alert
	 * @param extras
	 * @param tags 
	 */
	public static void pushIosNotificationByTag(String alert, Map<String, String> extras, String... tags){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_ios_tag_notification(alert, extras, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to Android&IOS by registrationID 
	 * @param title 
	 * @param alert
	 * @param extras
	 * @param registrationID 
	 */
	public static void pushAndroidIosNotificationByRegistrationID(String title, String alert, Map<String, String> extras, String... registrationID){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (registrationID == null || registrationID.length == 0) {
			log.info("registrationID is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_registrationId_notification(title, alert, extras, registrationID);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to Android&IOS by tag 
	 * @param title 
	 * @param alert
	 * @param extras
	 * @param tags 
	 */
	public static void pushAndroidIosNotificationByTags(String title, String alert, Map<String, String> extras, String... tags){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (tags == null || tags.length == 0) {
			log.info("tags is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_tag_notification(title, alert, extras, tags);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	/**
	 * push Notification to Android&IOS by alias 
	 * @param title 
	 * @param alert
	 * @param extras
	 * @param alias 
	 */
	public static void pushAndroidIosNotificationByAlias(String title, String alert, Map<String, String> extras, String... alias){

		if (alert == null || alert.isEmpty()) {
			log.info("Notification content is empty.");
			return;
		}
		if (alias == null || alias.length == 0) {
			log.info("alias is empty.");
			return;
		}
     	jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
     	pushPayload = buildPushObject_android_ios_alias_notification(title, alert, extras, alias);
     	try {
     		pushResult = jpushClient.sendPush(pushPayload);
         	log.info("push result is " + pushResult.isResultOK());
		} catch (APIConnectionException e) {
            // Connection error, should retry later
        	log.error("Connection error,try again later", e);
		} catch (APIRequestException e) {
            // Should review the error, and fix the request
        	log.error("Should review the error, and fix the request", e);
        	log.info("HTTP Status: " + e.getStatus());
        	log.info("Error Code: " + e.getErrorCode());
        	log.info("Error Notification: " + e.getErrorMessage());
        }
	}
	
	public static PushPayload buildPushObject_android_tag_alert(String title, String msgContent, String... tags) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.android())
                .setAudience(Audience.tag(tags))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}
	
	public static PushPayload buildPushObject_ios_tag_alert(String title, String msgContent, String... tags) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.tag(tags))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}
	
	public static PushPayload buildPushObject_android_ios_tag_alert(String title, String msgContent, String... tags) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.tag(tags))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}
	
	public static PushPayload buildPushObject_android_ios_alias_alert(String title, String msgContent, String... alias) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.alias(alias))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}

	public static PushPayload buildPushObject_android_ios_registrationId_alert(String title, String msgContent, String... registrationID) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.registrationId(registrationID))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}
	
	public static PushPayload buildPushObject_all_registrationId_alert(String title, String msgContent, String... registrationID) {
		return PushPayload.newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.registrationId(registrationID))
                .setMessage(Message.newBuilder()
                        .setTitle(title)
                        .setMsgContent(msgContent)
                        .build())
                .build();
	}
	
    public static PushPayload buildPushObject_android_tag_notification(String title, String alert, Map<String, String> extras, String... tags) {
    	return PushPayload.newBuilder()
                .setPlatform(Platform.android())
                .setAudience(Audience.tag(tags))
                .setNotification(Notification.android(alert, title, extras))
                .build();
    }
    
    public static PushPayload buildPushObject_ios_tag_notification(String alert, Map<String, String> extras, String... tags) {
    	return PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.tag(tags))
                .setNotification(Notification.ios(alert, extras))
                .build();
    }
    
    public static PushPayload buildPushObject_android_ios_registrationId_notification(String title, String alert, Map<String, String> extras, String... registrationId) {
    	return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.registrationId(registrationId))
                .setNotification(Notification.newBuilder()
                		.addPlatformNotification(AndroidNotification.newBuilder()
                				.setAlert(alert)
                				.setTitle(title)
                				.addExtras(extras)
                				.build())
                		.addPlatformNotification(IosNotification.newBuilder()
                			    .setAlert(alert)
                			    .addExtras(extras)
                			    .build())
                		.build())
                .build();
    }
    
    public static PushPayload buildPushObject_android_ios_tag_notification(String title, String alert, Map<String, String> extras, String... tags) {
    	return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.tag(tags))
                .setNotification(Notification.newBuilder()
                		.addPlatformNotification(AndroidNotification.newBuilder()
                				.setAlert(alert)
                				.setTitle(title)
                				.addExtras(extras)
                				.build())
                		.addPlatformNotification(IosNotification.newBuilder()
                			    .setAlert(alert)
                			    .addExtras(extras)
                			    .build())
                		.build())
                .build();
    }
    
    public static PushPayload buildPushObject_android_ios_alias_notification(String title, String alert, Map<String, String> extras, String... alias) {
    	return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.alias(alias))
                .setNotification(Notification.newBuilder()
                		.addPlatformNotification(AndroidNotification.newBuilder()
                				.setAlert(alert)
                				.setTitle(title)
                				.addExtras(extras)
                				.build())
                		.addPlatformNotification(IosNotification.newBuilder()
                			    .setAlert(alert)
                			    .addExtras(extras)
                			    .build())
                		.build())
                .build();
    }
}
